<script type="text/javascript" src="/static/Js/plupload/moxie.js"></script>
<script type="text/javascript" src="/static/Js/plupload/plupload.dev.js"></script>
<script type="text/javascript" src="/static/Js/plupload/i18n/zh_CN.js"></script>
<script type="text/javascript" src="/static/Js/qiniu.js"></script>
<script type="text/javascript" src="/static/Js/ui.js"></script>
<form id="friendlinkaddfm" method="post">
<input type="hidden" name="id" value="<?php echo $dataset['id'];?>" />
<table border="0" width="100%" cellspacing="1" cellpadding="5" bgcolor="#c4d3e1" style="text-align:left; line-height:18px;">
		<tr bgcolor="#FFFFFF">
			<td style="line-height:30px;"  width="20%">标题：</td>
			<td width="80%"><input name="title" type="text" style="width:400px;" class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox" placeholder="请输入标题.."  required="true"  value="<?php echo $dataset['title'];?>" ></td>
		</tr>
		<tr bgcolor="#FFFFFF">
			<td style="line-height:30px;"  width="20%">链接：</td>
			<td width="80%"><input name="links" type="text" style="width:400px;"  class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox" placeholder="请输入链接.." value="<?php echo $dataset['links'];?>" ></td>
		</tr>
		<tr bgcolor="#FFFFFF">
			<td style="line-height:30px;"  width="20%">排序：</td>
			<td width="80%"><input name="sortorder" type="text" class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox" placeholder="请输入排序.." value="<?php echo $dataset['sortorder'];?>" ></td>
		</tr>
		<tr bgcolor="#FFFFFF">
			<td style="line-height:30px;"  width="20%">状态：</td>
			<td width="80%"><input name="status" type="checkbox" class="textbox-prompt" value="1" <?php if($dataset['status']==1){echo 'checked="checked"';}?> >激活</td>
		</tr>
		<tr bgcolor="#FFFFFF">
			<td style="line-height:30px;"  width="20%">图片：</td>
			<td width="80%">
			<div title="个人证件">
				<div class="col-md-12">
					<div id="friendlinkaddcontainer" style="background-color:#F9F9F4">
						<a class="btn btn-default btn-lg" id="friendlinkaddpickfiles" href="#" >
							<i class="glyphicon glyphicon-plus"></i>
							<div style="padding:20px;">点击上传新图片，或者将新图片拖至此处，此处仅会保存一张图片。</div>
						</a>
					</div>
				</div>
				<div style="display:none" id="success" class="col-md-12">
					<div class="alert-success">
						队列全部文件处理完毕
					</div>
				</div>
				<div class="col-md-12 ">
					<table id="friendlinkadduploadtable" class="table table-striped table-hover text-left" id="fsUploadProgressTable1"  style="margin-top:20px; width:96%; display:none;">
						<thead>
						  <tr>
							<th width="20%"  class="col-md-4">图片</th>
							<th width="10%"  class="col-md-2">字节</th>
							<th width="70%"  class="col-md-6">网络文件</th>
						  </tr>
						</thead>
						<tbody id="friendlinkaddfsUploadProgress">
						</tbody>
					</table>
				</div>
			</div>
			</td>
		</tr>
</table>
</form>

<script>
$(function(){
		$('#friendlinkaddsubmit').click(function(data){
				$('#friendlinkaddfm').form('submit', {
					url:'/admin/main/friendlinkinsert',
					success: function(data){
						var data = eval('(' + data + ')');
						if(data.code=='200'){
								$.messager.show({
										title:'提示',
										msg:data.msg,
										timeout:3000,
										showType:'slide'
								});
								$('#friendlinkaddfm').form('clear');
								$("#friendlinkdlg").dialog('close');
								$("#friendlink").datagrid('reload');
						}else{
								$.messager.alert('提示',data.msg,'warning');
						}
					}
				});
		})
		var uploader2 = Qiniu.uploader({
				runtimes: 'html5,flash,html4', //上传模式,依次退化
				browse_button: 'friendlinkaddpickfiles', //上传选择的点选按钮，**必需**
				uptoken_url: '/admin/main/uptoken', //Ajax请求upToken的Url，**强烈建议设置**（服务端提供）
				domain: 'http://img.uu235.com/', //bucket 域名，下载资源时用到，**必需**
				container: 'friendlinkaddcontainer', //上传区域DOM ID，默认是browser_button的父元素，
				max_file_size: '5mb', //最大文件体积限制
				flash_swf_url: '/static/Js/plupload/Moxie.swf', //引入flash,相对路径
				max_retries: 3, //上传失败最大重试次数
				dragdrop: true, //开启可拖曳上传
				drop_element: 'friendlinkaddcontainer', //拖曳上传区域元素的ID，拖曳文件或文件夹后可触发上传
				chunk_size: '2mb', //分块上传时，每片的体积
				auto_start: true, //选择文件后自动上传，若关闭需要自己绑定事件触发上传
				unique_names: true,
				init: {
						'FilesAdded': function(up, files) {
							$('#friendlinkadduploadtable').show();
							$('#success').hide();
							plupload.each(files, function(file) {
								var progress = new FileProgress(file, 'friendlinkaddfsUploadProgress');
								progress.setStatus("等待...");
								progress.bindUploadCancel(up);
							});
						},
						'BeforeUpload': function(up, file) {
							var progress = new FileProgress(file, 'friendlinkaddfsUploadProgress');
							var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
							if (up.runtime === 'html5' && chunk_size) {
								progress.setChunkProgess(chunk_size);
							}
						},
						'UploadProgress': function(up, file) {
							var progress = new FileProgress(file, 'friendlinkaddfsUploadProgress');
							var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
							progress.setProgress(file.percent + "%", file.speed, chunk_size);
						},
						'UploadComplete': function() {
							$('#success').hide();
						},
						'FileUploaded': function(up, file, info) {
							var progress = new FileProgress(file, 'friendlinkaddfsUploadProgress');
							progress.setComplete(up, info, 1);
						},
						'Error': function(up, err, errTip) {
							$('#friendlinkadduploadtable').show();
							var progress = new FileProgress(err.file, 'friendlinkaddfsUploadProgress');
							progress.setError();
							progress.setStatus(errTip);
						}
				}
		})
});
</script>
